<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.dao.UserDao">
    <select id="findAll" resultType="com.example.entity.User">
        SELECT * FROM user
    </select>

    <select id="findById" parameterType="int" resultType="com.example.entity.User">
        SELECT * FROM user WHERE id = #{id}
    </select>

    <insert id="save" parameterType="com.example.entity.User">
        INSERT INTO user(username, password)
        VALUES (#{username}, #{password})
    </insert>

    <update id="update" parameterType="com.example.entity.User">
        UPDATE user
        SET username = #{username},
        password = #{password}
        WHERE id = #{id}
    </update>

    <delete id="delete" parameterType="int">
        DELETE FROM user WHERE id = #{id}
    </delete>
</mapper>